﻿<Application x:Class="Bend.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <!-- Color Palette -->
        <SolidColorBrush x:Key="BackgroundBrush" Color="#141414" />
        <SolidColorBrush x:Key="ForegroundBrush" Color="Silver" />
        <SolidColorBrush x:Key="ScrollButtonBrush" Color="#999999"/>
        <SolidColorBrush x:Key="LogoForegroundBrush" Color="Black"/>
        <SolidColorBrush x:Key="LogoBackgroundBrush" Color="#FFF3F31A"/>
        <SolidColorBrush x:Key="MenuSelectedBackgroundBrush" Color="#DDDDDD" />

        <!-- SCROLLBAR TEMPLATES -->
        <Style x:Key="Scrollbar_LineButton" TargetType="{x:Type RepeatButton}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Border Background="{DynamicResource BackgroundBrush}">
                            <ContentPresenter x:Name="ContentSite" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Foreground" Value="{DynamicResource ScrollButtonBrush}" />
            <Setter Property="FontSize" Value="20px" />
            <Setter Property="FontFamily" Value="Webdings" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="20"/>
            <Setter Property="Height" Value="20"/>
        </Style>

        <Style x:Key="ScrollBar_TrackRepeater"  TargetType="{x:Type RepeatButton}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="IsTabStop" Value="false" />
            <Setter Property="Focusable" Value="false" />
            <Setter Property="Command" Value="ScrollBar.PageUpCommand" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Rectangle Fill="{DynamicResource BackgroundBrush}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ScrollBar_UpTrack" 
            BasedOn="{StaticResource ScrollBar_TrackRepeater}" 
            TargetType="{x:Type RepeatButton}">
            <Setter Property="Command" Value="ScrollBar.PageUpCommand" />
        </Style>
        <Style x:Key="ScrollBar_DownTrack" 
            BasedOn="{StaticResource ScrollBar_TrackRepeater}" 
            TargetType="{x:Type RepeatButton}">
            <Setter Property="Command" Value="ScrollBar.PageDownCommand" />
        </Style>


        <Style x:Key="ScrollBar_LeftTrack" 
            BasedOn="{StaticResource ScrollBar_TrackRepeater}" 
            TargetType="{x:Type RepeatButton}">
            <Setter Property="Command" Value="ScrollBar.PageLeftCommand" />
        </Style>

        <Style x:Key="ScrollBar_RightTrack" 
            BasedOn="{StaticResource ScrollBar_TrackRepeater}" 
            TargetType="{x:Type RepeatButton}">
            <Setter Property="Command" Value="ScrollBar.PageRightCommand" />
        </Style>

        <Style x:Key="ScrollBar_VerticalThumb" TargetType="{x:Type Thumb}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border BorderBrush="{DynamicResource BackgroundBrush}" BorderThickness="3" Background="#505050" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="MinHeight" Value="40" />
            <Setter Property="MinWidth" Value="17" />
        </Style>

        <Style x:Key="ScrollBar_HorizontalThumb" TargetType="{x:Type Thumb}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border BorderBrush="{DynamicResource BackgroundBrush}" BorderThickness="3" Background="#505050" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="MinHeight" Value="17" />
            <Setter Property="MinWidth" Value="40" />
        </Style>

        <Style TargetType="{x:Type ScrollBar}">
            <Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
            <Setter Property="MinWidth" Value="20" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollBar}">
                        <Grid Background="{DynamicResource BackgroundBrush}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20" />
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="20" />
                            </Grid.RowDefinitions>
                            <Border Grid.Column="1" Background="{DynamicResource BackgroundBrush}"/>
                            <RepeatButton Grid.Row="0" Style="{DynamicResource Scrollbar_LineButton}" Command="ScrollBar.LineUpCommand" Content="5" />
                            <Track Grid.Row="1" Name="PART_Track" IsDirectionReversed="true">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{DynamicResource ScrollBar_UpTrack}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{DynamicResource ScrollBar_VerticalThumb}"/>
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{DynamicResource ScrollBar_DownTrack}"/>
                                </Track.IncreaseRepeatButton>
                            </Track>
                            <RepeatButton Grid.Row="2" Style="{DynamicResource Scrollbar_LineButton}" Command="ScrollBar.LineDownCommand" Content="6" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Orientation" Value="Horizontal" >
                    <Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
                    <Setter Property="MinHeight" Value="20" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ScrollBar}">
                                <Grid Background="{DynamicResource BackgroundBrush}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="20"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="20" />
                                        <ColumnDefinition Width="2*"/>
                                        <ColumnDefinition Width="20" />
                                    </Grid.ColumnDefinitions>
                                    <Border Grid.Column="2" Background="{DynamicResource BackgroundBrush}"/>
                                    <RepeatButton Grid.Column="1" Style="{DynamicResource Scrollbar_LineButton}" Command="ScrollBar.LineLeftCommand" Content="3" />
                                    <Track Grid.Column="2" Name="PART_Track">
                                        <Track.DecreaseRepeatButton>
                                            <RepeatButton Style="{DynamicResource ScrollBar_LeftTrack}"/>
                                        </Track.DecreaseRepeatButton>
                                        <Track.Thumb>
                                            <Thumb Style="{DynamicResource ScrollBar_HorizontalThumb}"/>
                                        </Track.Thumb>
                                        <Track.IncreaseRepeatButton>
                                            <RepeatButton Style="{DynamicResource ScrollBar_RightTrack}"/>
                                        </Track.IncreaseRepeatButton>
                                    </Track>
                                    <RepeatButton Grid.Column="3" Style="{DynamicResource Scrollbar_LineButton}" Command="ScrollBar.LineRightCommand" Content="4" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>

        <!--Custom Context Menu Template (Provides Rounded Border and Drop Shadow) -->
        <Style TargetType="{x:Type ContextMenu}">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="Grid.IsSharedSizeScope" Value="True" />
            <Setter Property="HasDropShadow" Value="True" />
            <Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
            <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}" />
            <Setter Property = "BitmapEffect" >
                <Setter.Value>
                    <DropShadowBitmapEffect Color="Silver" Direction="0" ShadowDepth="0" Softness="0.5" Opacity="0.5"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Margin" Value="30"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContextMenu}">
                        <Border x:Name="Border" Background="{DynamicResource BackgroundBrush}" BorderThickness="1" BorderBrush="{DynamicResource ScrollButtonBrush}">
                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasDropShadow" Value="true">
                                <Setter TargetName="Border" Property="Padding" Value="0,3,0,3" />
                                <Setter TargetName="Border" Property="CornerRadius" Value="4" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--Custom Template for Menu Item Seperator-->
        <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="Separator">
            <Setter Property="Height" Value="1"/>
            <Setter Property="Margin" Value="8,5,8,5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Separator">
                        <Border BorderBrush="{DynamicResource ScrollButtonBrush}" BorderThickness="1"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--Custom Tempalte for Menu Items-->
        <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="MenuItem">
            <Border Name="Border" >
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                        <ColumnDefinition Width="13"/>
                    </Grid.ColumnDefinitions>
                    <ContentPresenter Name="Icon" Margin="8,0,8,0" VerticalAlignment="Center" ContentSource="Icon"/>
                    <Border Name="Check" Width="13" Height="13" Visibility="Collapsed" Margin="6,0,6,0" Background="{DynamicResource BackgroundBrush}" BorderThickness="1" BorderBrush="{DynamicResource ScrollButtonBrush}">
                        <Path Name="CheckMark" Width="7" Height="7" Visibility="Hidden" SnapsToDevicePixels="False" Stroke="{DynamicResource ForegroundBrush}" StrokeThickness="2" Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                    </Border>
                    <ContentPresenter Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/>
                    <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,0,2" DockPanel.Dock="Right" Opacity="0.5"/>
                </Grid>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="Icon" Value="{x:Null}">
                    <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
                </Trigger>
                <Trigger Property="IsChecked" Value="true">
                    <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
                </Trigger>
                <Trigger Property="IsCheckable" Value="true">
                    <Setter TargetName="Check" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
                </Trigger>
                <Trigger Property="IsHighlighted" Value="true">
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MenuSelectedBackgroundBrush}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Opacity" Value="0.3"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Application.Resources>
</Application>
